use strict;
use warnings;
use Data::Dumper;

require CleverBotWatcher;
my $cbw = new CleverBotWatcher;
my $conf = $cbw->load_conf() or &msg( $cbw->error ); 
my $current_key = 1;

# {
#	1 => {
# 	    icon_name => "icon1.ico",
# 	    tip  => "exists 3 ...",
# 	    cmd  => "explorer ...",
#	    ico  => undef, # will exist later
# 	},
# 	{...},
# }

print "free_console=", $cbw->free_console(), "\n";


for my $key ( keys %$conf ) {
    $conf->{$key}->{ico} = "created_icon_".$conf->{$key}->{icon_name};
}

print Dumper "conf:", $conf;

print "after starting: \n-icon => $conf->{ $current_key }->{ico},\n  -tip => $conf->{ $current_key }->{tip}\n";

print "NI_CLICK=", "$conf->{ $current_key }->{cmd}";


while (1) {
 print "\nTimer ewent ...\n";
 my $index = $cbw->start( debug=>1 ) or msg( $cbw->error , "no_show" );
 print "index=$index\n";
 &msg( $cbw->msg , "no_show" );
 $current_key = $index if $index;
 print "current_index=$current_key\n";
 print "Modify( -id => 1, -tip => $conf->{ $current_key }->{ tip } , -icon => $conf->{ $current_key }->{ ico } )";
 sleep 5;
}


sub msg{
  my $text = shift;
  return 1 if !$text;
  my $no_show = shift;
  print "$text\n";
}
